home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / BORLAND TURBO / BOLEUI32.PAK / BOLESTD.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  32.6 KB  |  891 lines

  1. /*************************************************************************
  2. **
  3. **    OLE 2.0 Standard Utilities
  4. **
  5. **    bolestd.h
  6. **
  7. **    This file contains file contains data structure defintions,
  8. **    function prototypes, constants, etc. for the common OLE 2.0
  9. **    utilities.
  10. **    These utilities include the following:
  11. **          Debuging Assert/Verify macros
  12. **          HIMETRIC conversion routines
  13. **          reference counting debug support
  14. **          OleStd API's for common compound-document app support
  15. **
  16. *************************************************************************/
  17. /*
  18.  *      C/C++ Run Time Library - Version 6.5
  19.  *
  20.  *      Copyright (c) 1994 by Borland International
  21.  *      All Rights Reserved.
  22.  *
  23.  */
  24.  
  25. #ifndef _BOLESTD_H_ 
  26. #define _BOLESTD_H_
  27.  
  28.  
  29. #ifndef RC_INVOKED
  30. #include <windows.h>
  31. #include <shellapi.h>
  32. #include <ole2.h>
  33. #include <string.h>
  34. #endif
  35. #include "ansiapi.h"
  36.  
  37. // Win 4.0 specific style [may not be defined by older system headers]
  38. //
  39. #if !defined(DS_3DLOOK)
  40. #define DS_3DLOOK   0x04L
  41. #endif
  42.  
  43. // String table defines...
  44. #define  IDS_OLESTDNOCREATEFILE   700
  45. #define  IDS_OLESTDNOOPENFILE     701
  46. #define  IDS_OLESTDDISKFULL       702
  47.  
  48. #define IDS_OLE2UIPASTELINKEDTYPE  32311
  49. #define IDS_PSUNKNOWNTYPE          32417
  50.  
  51. #ifndef RC_INVOKED
  52.  
  53. // #pragma message ("INCLUDING BOLESTD.H from " __FILE__)
  54.  
  55. #if defined( __TURBOC__ ) || defined( WIN32 )
  56. #define _based(a)
  57. #endif
  58.  
  59. #include <dos.h>        // needed for filetime
  60. #include <commdlg.h>    // needed for LPPRINTDLG
  61. #include <shellapi.h>   // needed for HKEY
  62.  
  63. #if defined( _DEBUG )
  64. #define OleDbgQueryInterfaceMethod(lpUnk)   \
  65.       ((lpUnk) != NULL ? ((LPINTERFACEIMPL)(lpUnk))->cRef++ : 0)
  66. #define OleDbgAddRefMethod(lpThis, iface)   \
  67.       ((LPINTERFACEIMPL)(lpThis))->cRef++
  68.  
  69. #if _DEBUGLEVEL >= 2
  70. #define OleDbgReleaseMethod(lpThis, iface) \
  71.       (--((LPINTERFACEIMPL)(lpThis))->cRef == 0 ? \
  72.          OleDbgOut("\t" iface "* RELEASED (cRef == 0)\r\n"),1 : \
  73.           (((LPINTERFACEIMPL)(lpThis))->cRef < 0) ? \
  74.             ( \
  75.                DebugBreak(), \
  76.                OleDbgOut(  \
  77.                   "\tERROR: " iface "* RELEASED TOO MANY TIMES\r\n") \
  78.             ),1 : \
  79.             1)
  80.  
  81. #else       // if _DEBUGLEVEL < 2
  82. #define OleDbgReleaseMethod(lpThis, iface) \
  83.       (--((LPINTERFACEIMPL)(lpThis))->cRef == 0 ? \
  84.          1 : \
  85.           (((LPINTERFACEIMPL)(lpThis))->cRef < 0) ? \
  86.             ( \
  87.                OleDbgOut(  \
  88.                   "\tERROR: " iface "* RELEASED TOO MANY TIMES\r\n") \
  89.       ),1 : \
  90.             1)
  91.  
  92. #endif      // if _DEBUGLEVEL < 2
  93.  
  94. #else       // ! defined (_DEBUG)
  95.  
  96. #define OleDbgQueryInterfaceMethod(lpUnk)
  97. #define OleDbgAddRefMethod(lpThis, iface)
  98. #define OleDbgReleaseMethod(lpThis, iface)
  99.  
  100. #endif      // if defined( _DEBUG )
  101.  
  102.  
  103. /*
  104.  * Some docfiles stuff
  105.  */
  106.  
  107. #define STGM_DFRALL (STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_DENY_WRITE)
  108. #define STGM_DFALL (STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE)
  109. #define STGM_SALL (STGM_READWRITE | STGM_SHARE_EXCLUSIVE)
  110.  
  111. /*
  112.  * Some Concurrency stuff
  113.  */
  114.  
  115. /* standard Delay (in msec) to wait before retrying an LRPC call.
  116. **    this value is returned from IMessageFilter::RetryRejectedCall
  117. */
  118. #define OLESTDRETRYDELAY    (DWORD)5000
  119.  
  120. /* Cancel the pending outgoing LRPC call.
  121. **    this value is returned from IMessageFilter::RetryRejectedCall
  122. */
  123. #define OLESTDCANCELRETRY   (DWORD)-1
  124.  
  125. /*
  126.  * Some Clipboard Copy/Paste & Drag/Drop support stuff
  127.  */
  128.  
  129. //Macro to set all FormatEtc fields
  130. #define SETFORMATETC(fe, cf, asp, td, med, li)   \
  131.    ((fe).cfFormat=cf, \
  132.     (fe).dwAspect=asp, \
  133.     (fe).ptd=td, \
  134.     (fe).tymed=med, \
  135.     (fe).lindex=li)
  136.  
  137. //Macro to set interesting FormatEtc fields defaulting the others.
  138. #define SETDEFAULTFORMATETC(fe, cf, med)  \
  139.    ((fe).cfFormat=cf, \
  140.     (fe).dwAspect=DVASPECT_CONTENT, \
  141.     (fe).ptd=NULL, \
  142.     (fe).tymed=med, \
  143.     (fe).lindex=-1)
  144.  
  145. // Macro to test if two FormatEtc structures are an exact match
  146. #define IsEqualFORMATETC(fe1, fe2)  \
  147.    (OleStdCompareFormatEtc(&(fe1), &(fe2))==0)
  148.  
  149. // Clipboard format strings
  150. #define CF_EMBEDSOURCE      TEXT("Embed Source")
  151. #define CF_EMBEDDEDOBJECT   TEXT("Embedded Object")
  152. #define CF_LINKSOURCE       TEXT("Link Source")
  153. #define CF_CUSTOMLINKSOURCE TEXT("Custom Link Source")
  154. #define CF_OBJECTDESCRIPTOR TEXT("Object Descriptor")
  155. #define CF_LINKSRCDESCRIPTOR TEXT("Link Source Descriptor")
  156. #define CF_OWNERLINK        TEXT("OwnerLink")
  157. #define CF_FILENAME         TEXT("FileName")
  158.  
  159. #ifdef NOT_YET
  160.  
  161. #define OleStdQueryOleObjectData(lpformatetc)   \
  162.    (((lpformatetc)->tymed & TYMED_ISTORAGE) ?    \
  163.          NOERROR : ResultFromScode(DV_E_FORMATETC))
  164.  
  165. #define OleStdQueryLinkSourceData(lpformatetc)   \
  166.    (((lpformatetc)->tymed & TYMED_ISTREAM) ?    \
  167.          NOERROR : ResultFromScode(DV_E_FORMATETC))
  168.  
  169. #define OleStdQueryObjectDescriptorData(lpformatetc)    \
  170.    (((lpformatetc)->tymed & TYMED_HGLOBAL) ?    \
  171.          NOERROR : ResultFromScode(DV_E_FORMATETC))
  172.  
  173. #define OleStdQueryFormatMedium(lpformatetc, tymd)  \
  174.    (((lpformatetc)->tymed & tymd) ?    \
  175.          NOERROR : ResultFromScode(DV_E_FORMATETC))
  176.  
  177. // Make an independent copy of a MetafilePict
  178. #define OleStdCopyMetafilePict(hpictin, phpictout)  \
  179.    (*(phpictout) = OleDuplicateData(hpictin,CF_METAFILEPICT,GHND|GMEM_SHARE))
  180.  
  181.  
  182. // REVIEW: these need to be added to OLE2.H
  183. #if !defined( DD_DEFSCROLLINTERVAL )
  184. #define DD_DEFSCROLLINTERVAL    50
  185. #endif
  186.  
  187. #if !defined( DD_DEFDRAGDELAY )
  188. #define DD_DEFDRAGDELAY         200
  189. #endif
  190.  
  191. #if !defined( DD_DEFDRAGMINDIST )
  192. #define DD_DEFDRAGMINDIST       2
  193. #endif
  194. #endif  // NOT_YET
  195.  
  196.  
  197. #ifdef NOT_YET
  198. /* OleStdGetDropEffect
  199. ** -------------------
  200. **
  201. ** Convert a keyboard state into a DROPEFFECT.
  202. **
  203. ** returns the DROPEFFECT value derived from the key state.
  204. **    the following is the standard interpretation:
  205. **          no modifier -- Default Drop     (NULL is returned)
  206. **          CTRL        -- DROPEFFECT_COPY
  207. **          SHIFT       -- DROPEFFECT_MOVE
  208. **          CTRL-SHIFT  -- DROPEFFECT_LINK
  209. **
  210. **    Default Drop: this depends on the type of the target application.
  211. **    this is re-interpretable by each target application. a typical
  212. **    interpretation is if the drag is local to the same document
  213. **    (which is source of the drag) then a MOVE operation is
  214. **    performed. if the drag is not local, then a COPY operation is
  215. **    performed.
  216. */
  217. #define OleStdGetDropEffect(grfKeyState)    \
  218.    ( (grfKeyState & MK_CONTROL) ?          \
  219.       ( (grfKeyState & MK_SHIFT) ? DROPEFFECT_LINK : DROPEFFECT_COPY ) :  \
  220.       ( (grfKeyState & MK_SHIFT) ? DROPEFFECT_MOVE : 0 ) )
  221.  
  222.  
  223. /* The OLEUIPASTEFLAG enumeration is used by the OLEUIPASTEENTRY structure.
  224.  *
  225.  * OLEUIPASTE_ENABLEICON    If the container does not specify this flag for the entry in the
  226.  *   OLEUIPASTEENTRY array passed as input to OleUIPasteSpecial, the DisplayAsIcon button will be
  227.  *   unchecked and disabled when the the user selects the format that corresponds to the entry.
  228.  *
  229.  * OLEUIPASTE_PASTEONLY     Indicates that the entry in the OLEUIPASTEENTRY array is valid for pasting only.
  230.  * OLEUIPASTE_PASTE         Indicates that the entry in the OLEUIPASTEENTRY array is valid for pasting. It
  231.  *   may also be valid for linking if any of the following linking flags are specified.
  232.  *
  233.  * If the entry in the OLEUIPASTEENTRY array is valid for linking, the following flags indicate which link
  234.  * types are acceptable by OR'ing together the appropriate OLEUIPASTE_LINKTYPE<#> values.
  235.  * These values correspond as follows to the array of link types passed to OleUIPasteSpecial:
  236.  *   OLEUIPASTE_LINKTYPE1=arrLinkTypes[0]
  237.  *   OLEUIPASTE_LINKTYPE2=arrLinkTypes[1]
  238.  *   OLEUIPASTE_LINKTYPE3=arrLinkTypes[2]
  239.  *   OLEUIPASTE_LINKTYPE4=arrLinkTypes[3]
  240.  *   OLEUIPASTE_LINKTYPE5=arrLinkTypes[4]
  241.  *   OLEUIPASTE_LINKTYPE6=arrLinkTypes[5]
  242.  *   OLEUIPASTE_LINKTYPE7=arrLinkTypes[6]
  243.  *  OLEUIPASTE_LINKTYPE8=arrLinkTypes[7]
  244.  *
  245.  * where,
  246.  *   UINT arrLinkTypes[8] is an array of registered clipboard formats for linking. A maximium of 8 link
  247.  *   types are allowed.
  248.  */
  249.  
  250. typedef enum tagOLEUIPASTEFLAG
  251. {
  252.    OLEUIPASTE_ENABLEICON    = 2048,     // enable display as icon
  253.    OLEUIPASTE_PASTEONLY     = 0,
  254.    OLEUIPASTE_PASTE         = 512,
  255.    OLEUIPASTE_LINKANYTYPE   = 1024,
  256.    OLEUIPASTE_LINKTYPE1     = 1,
  257.    OLEUIPASTE_LINKTYPE2     = 2,
  258.    OLEUIPASTE_LINKTYPE3     = 4,
  259.    OLEUIPASTE_LINKTYPE4     = 8,
  260.    OLEUIPASTE_LINKTYPE5     = 16,
  261.    OLEUIPASTE_LINKTYPE6     = 32,
  262.    OLEUIPASTE_LINKTYPE7     = 64,
  263.    OLEUIPASTE_LINKTYPE8     = 128
  264. } OLEUIPASTEFLAG;
  265.  
  266. /*
  267.  * PasteEntry structure
  268.  * --------------------
  269.  * An array of OLEUIPASTEENTRY entries is specified for the PasteSpecial dialog
  270.  * box. Each entry includes a FORMATETC which specifies the formats that are
  271.  * acceptable, a string that is to represent the format in the  dialog's list
  272.  * box, a string to customize the result text of the dialog and a set of flags
  273.  * from the OLEUIPASTEFLAG enumeration.  The flags indicate if the entry is
  274.  * valid for pasting only, linking only or both pasting and linking. If the
  275.  * entry is valid for linking, the flags indicate which link types are
  276.  * acceptable by OR'ing together the appropriate OLEUIPASTE_LINKTYPE<#> values.
  277.  * These values correspond to the array of link types as follows:
  278.  *   OLEUIPASTE_LINKTYPE1=arrLinkTypes[0]
  279.  *   OLEUIPASTE_LINKTYPE2=arrLinkTypes[1]
  280.  *   OLEUIPASTE_LINKTYPE3=arrLinkTypes[2]
  281.  *   OLEUIPASTE_LINKTYPE4=arrLinkTypes[3]
  282.  *   OLEUIPASTE_LINKTYPE5=arrLinkTypes[4]
  283.  *   OLEUIPASTE_LINKTYPE6=arrLinkTypes[5]
  284.  *   OLEUIPASTE_LINKTYPE7=arrLinkTypes[6]
  285.  *   OLEUIPASTE_LINKTYPE8=arrLinkTypes[7]
  286.  *   UINT arrLinkTypes[8]; is an array of registered clipboard formats
  287.  *                        for linking. A maximium of 8 link types are allowed.
  288.  */
  289.  
  290. typedef struct tagOLEUIPASTEENTRYA
  291. {
  292.    FORMATETC        fmtetc;            // Format that is acceptable. The paste
  293.                               //   dialog checks if this format is
  294.                               //   offered by the object on the
  295.                               //   clipboard and if so offers it for
  296.                               //   selection to the user.
  297.    LPCSTR           lpstrFormatName;   // String that represents the format to the user. Any %s
  298.                               //   in this string is replaced by the FullUserTypeName
  299.                               //   of the object on the clipboard and the resulting string
  300.                               //   is placed in the list box of the dialog. Atmost
  301.                               //   one %s is allowed. The presence or absence of %s indicates
  302.                               //   if the result text is to indicate that data is
  303.                               //   being pasted or that an object that can be activated by
  304.                               //   an application is being pasted. If %s is
  305.                               //   present, the result-text says that an object is being pasted.
  306.                               //   Otherwise it says that data is being pasted.
  307.    LPCSTR           lpstrResultText;   // String to customize the result text of the dialog when
  308.                               //  the user selects the format correspoding to this
  309.                               //  entry. Any %s in this string is replaced by the the application
  310.                               //  name or FullUserTypeName of the object on
  311.                               //  the clipboard. Atmost one %s is allowed.
  312.    DWORD            dwFlags;           // Values from OLEUIPASTEFLAG enum
  313.    DWORD            dwScratchSpace;    // Scratch space available to be used
  314.                               //   by routines which loop through an
  315.                               //   IEnumFORMATETC* to mark if the
  316.                               //   PasteEntry format is available.
  317.                               //   this field CAN be left uninitialized.
  318. } OLEUIPASTEENTRYA, *POLEUIPASTEENTRYA, FAR *LPOLEUIPASTEENTRYA;
  319. typedef struct tagOLEUIPASTEENTRYW
  320. {
  321.    FORMATETC        fmtetc;            // Format that is acceptable. The paste
  322.                               //   dialog checks if this format is
  323.                               //   offered by the object on the
  324.                               //   clipboard and if so offers it for
  325.                               //   selection to the user.
  326.    LPCWSTR           lpstrFormatName;   // String that represents the format to the user. Any %s
  327.                               //   in this string is replaced by the FullUserTypeName
  328.                               //   of the object on the clipboard and the resulting string
  329.                               //   is placed in the list box of the dialog. Atmost
  330.                               //   one %s is allowed. The presence or absence of %s indicates
  331.                               //   if the result text is to indicate that data is
  332.                               //   being pasted or that an object that can be activated by
  333.                               //   an application is being pasted. If %s is
  334.                               //   present, the result-text says that an object is being pasted.
  335.                               //   Otherwise it says that data is being pasted.
  336.    LPCWSTR           lpstrResultText;   // String to customize the result text of the dialog when
  337.                               //  the user selects the format correspoding to this
  338.                               //  entry. Any %s in this string is replaced by the the application
  339.                               //  name or FullUserTypeName of the object on
  340.                               //  the clipboard. Atmost one %s is allowed.
  341.    DWORD            dwFlags;           // Values from OLEUIPASTEFLAG enum
  342.    DWORD            dwScratchSpace;    // Scratch space available to be used
  343.                               //   by routines which loop through an
  344.                               //   IEnumFORMATETC* to mark if the
  345.                               //   PasteEntry format is available.
  346.                               //   this field CAN be left uninitialized.
  347. } OLEUIPASTEENTRYW, *POLEUIPASTEENTRYW, FAR *LPOLEUIPASTEENTRYW;
  348. #ifdef UNICODE
  349. typedef OLEUIPASTEENTRYW OLEUIPASTEENTRY;
  350. typedef POLEUIPASTEENTRYW POLEUIPASTEENTRY;
  351. typedef LPOLEUIPASTEENTRYW LPOLEUIPASTEENTRY;
  352. #else
  353. typedef OLEUIPASTEENTRYA OLEUIPASTEENTRY;
  354. typedef POLEUIPASTEENTRYA POLEUIPASTEENTRY;
  355. typedef LPOLEUIPASTEENTRYA LPOLEUIPASTEENTRY;
  356. #endif
  357.  
  358. #define OLESTDDROP_NONE         0
  359. #define OLESTDDROP_DEFAULT      1
  360. #define OLESTDDROP_NONDEFAULT   2
  361.  
  362. #endif // NOT_YET
  363.  
  364. /*
  365.  * Some misc stuff
  366.  */
  367.  
  368. #define EMBEDDINGFLAG "Embedding"     // Cmd line switch for launching a srvr
  369.  
  370. #define HIMETRIC_PER_INCH   2540      // number HIMETRIC units per inch
  371. #define PTS_PER_INCH        72        // number points (font size) per inch
  372.  
  373. #if 0
  374. #define MAP_PIX_TO_LOGHIM(x,ppli)   MulDiv(HIMETRIC_PER_INCH, (x), (ppli))
  375. #define MAP_LOGHIM_TO_PIX(x,ppli)   MulDiv((ppli), (x), HIMETRIC_PER_INCH)
  376. #else
  377.  
  378. #define MAP_PIX_TO_LOGHIM(pixel, pixelsPerInch) \
  379.         ((ULONG) ((((ULONG)HIMETRIC_PER_INCH) * pixel + (pixelsPerInch >> 1)) / pixelsPerInch))
  380.  
  381. #define MAP_LOGHIM_TO_PIX(hiMetric, pixelsPerInch) \
  382.     (UINT) ((((double) hiMetric) * pixelsPerInch + (HIMETRIC_PER_INCH >> 1)) / HIMETRIC_PER_INCH)
  383.  
  384. #endif
  385.  
  386. // Returns TRUE if all fields of the two Rect's are equal, else FALSE.
  387. #define AreRectsEqual(lprc1, lprc2)     \
  388.    (((lprc1->top == lprc2->top) &&     \
  389.      (lprc1->left == lprc2->left) &&   \
  390.      (lprc1->right == lprc2->right) && \
  391.      (lprc1->bottom == lprc2->bottom)) ? TRUE : FALSE)
  392.  
  393. #define LSTRCPYN(lpdst, lpsrc, cch) \
  394. (\
  395.    (lpdst)[(cch)-1] = '\0', \
  396.    ((cch)>1 ? _fstrncpy(lpdst, lpsrc, (cch)-1) : 0)\
  397. )
  398.  
  399.  
  400.  
  401. /****** DEBUG Stuff *****************************************************/
  402.  
  403. #ifdef _DEBUG
  404.  
  405. #if !defined( _DBGTRACE )
  406. #define _DEBUGLEVEL 2
  407. #else
  408. #define _DEBUGLEVEL _DBGTRACE
  409. #endif
  410.  
  411.  
  412. #if defined( NOASSERT )
  413.  
  414. #define OLEDBGASSERTDATA
  415. #define OleDbgAssert(a)
  416. #define OleDbgAssertSz(a, b)
  417. #define OleDbgVerify(a)
  418. #define OleDbgVerifySz(a, b)
  419.  
  420. #else   // ! NOASSERT
  421.  
  422. #define OLEDBGASSERTDATA    \
  423.       static char _based(_segname("_CODE")) _szAssertFile[]= __FILE__;
  424.  
  425. #define OleDbgAssert(a) \
  426.       (!(a) ? FnAssert(#a, NULL, _szAssertFile, __LINE__) : (HRESULT)1)
  427.  
  428. #define OleDbgAssertSz(a, b)    \
  429.       (!(a) ? FnAssert(#a, b, _szAssertFile, __LINE__) : (HRESULT)1)
  430.  
  431. #define OleDbgVerify(a) \
  432.       OleDbgAssert(a)
  433.  
  434. #define OleDbgVerifySz(a, b)    \
  435.       OleDbgAssertSz(a, b)
  436.  
  437. #endif  // ! NOASSERT
  438.  
  439.  
  440. #define OLEDBGDATA_MAIN(szPrefix)   \
  441.       char near g_szDbgPrefix[] = szPrefix;    \
  442.       OLEDBGASSERTDATA
  443. #define OLEDBGDATA  \
  444.       extern char near g_szDbgPrefix[];    \
  445.       OLEDBGASSERTDATA
  446.  
  447. #define OLEDBG_BEGIN(lpsz) \
  448.       OleDbgPrintAlways(g_szDbgPrefix,lpsz,1);
  449.  
  450. #define OLEDBG_END  \
  451.       OleDbgPrintAlways(g_szDbgPrefix,"End\r\n",-1);
  452.  
  453. #define OleDbgOut(lpsz) \
  454.       OleDbgPrintAlways(g_szDbgPrefix,lpsz,0)
  455.  
  456. #define OleDbgOutNoPrefix(lpsz) \
  457.       OleDbgPrintAlways("",lpsz,0)
  458.  
  459. #define OleDbgOutRefCnt(lpsz,lpObj,refcnt)      \
  460.       OleDbgPrintRefCntAlways(g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  461.  
  462. #define OleDbgOutRect(lpsz,lpRect)      \
  463.       OleDbgPrintRectAlways(g_szDbgPrefix,lpsz,lpRect)
  464.  
  465. #define OleDbgOutHResult(lpsz,hr)   \
  466.       OleDbgPrintScodeAlways(g_szDbgPrefix,lpsz,GetScode(hr))
  467.  
  468. #define OleDbgOutScode(lpsz,sc) \
  469.       OleDbgPrintScodeAlways(g_szDbgPrefix,lpsz,sc)
  470.  
  471. #define OleDbgOut1(lpsz)    \
  472.       OleDbgPrint(1,g_szDbgPrefix,lpsz,0)
  473.  
  474. #define OleDbgOutNoPrefix1(lpsz)    \
  475.       OleDbgPrint(1,"",lpsz,0)
  476.  
  477. #define OLEDBG_BEGIN1(lpsz)    \
  478.       OleDbgPrint(1,g_szDbgPrefix,lpsz,1);
  479.  
  480. #define OLEDBG_END1 \
  481.       OleDbgPrint(1,g_szDbgPrefix,"End\r\n",-1);
  482.  
  483. #define OleDbgOutRefCnt1(lpsz,lpObj,refcnt)     \
  484.       OleDbgPrintRefCnt(1,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  485.  
  486. #define OleDbgOutRect1(lpsz,lpRect)     \
  487.       OleDbgPrintRect(1,g_szDbgPrefix,lpsz,lpRect)
  488.  
  489. #define OleDbgOut2(lpsz)    \
  490.       OleDbgPrint(2,g_szDbgPrefix,lpsz,0)
  491.  
  492. #define OleDbgOutNoPrefix2(lpsz)    \
  493.       OleDbgPrint(2,"",lpsz,0)
  494.  
  495. #define OLEDBG_BEGIN2(lpsz)    \
  496.       OleDbgPrint(2,g_szDbgPrefix,lpsz,1);
  497.  
  498. #define OLEDBG_END2 \
  499.       OleDbgPrint(2,g_szDbgPrefix,"End\r\n",-1);
  500.  
  501. #define OleDbgOutRefCnt2(lpsz,lpObj,refcnt)     \
  502.       OleDbgPrintRefCnt(2,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  503.  
  504. #define OleDbgOutRect2(lpsz,lpRect)     \
  505.       OleDbgPrintRect(2,g_szDbgPrefix,lpsz,lpRect)
  506.  
  507. #define OleDbgOut3(lpsz)    \
  508.       OleDbgPrint(3,g_szDbgPrefix,lpsz,0)
  509.  
  510. #define OleDbgOutNoPrefix3(lpsz)    \
  511.       OleDbgPrint(3,"",lpsz,0)
  512.  
  513. #define OLEDBG_BEGIN3(lpsz)    \
  514.       OleDbgPrint(3,g_szDbgPrefix,lpsz,1);
  515.  
  516. #define OLEDBG_END3 \
  517.       OleDbgPrint(3,g_szDbgPrefix,"End\r\n",-1);
  518.  
  519. #define OleDbgOutRefCnt3(lpsz,lpObj,refcnt)     \
  520.       OleDbgPrintRefCnt(3,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  521.  
  522. #define OleDbgOutRect3(lpsz,lpRect)     \
  523.       OleDbgPrintRect(3,g_szDbgPrefix,lpsz,lpRect)
  524.  
  525. #define OleDbgOut4(lpsz)    \
  526.       OleDbgPrint(4,g_szDbgPrefix,lpsz,0)
  527.  
  528. #define OleDbgOutNoPrefix4(lpsz)    \
  529.       OleDbgPrint(4,"",lpsz,0)
  530.  
  531. #define OLEDBG_BEGIN4(lpsz)    \
  532.       OleDbgPrint(4,g_szDbgPrefix,lpsz,1);
  533.  
  534. #define OLEDBG_END4 \
  535.       OleDbgPrint(4,g_szDbgPrefix,"End\r\n",-1);
  536.  
  537. #define OleDbgOutRefCnt4(lpsz,lpObj,refcnt)     \
  538.       OleDbgPrintRefCnt(4,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  539.  
  540. #define OleDbgOutRect4(lpsz,lpRect)     \
  541.       OleDbgPrintRect(4,g_szDbgPrefix,lpsz,lpRect)
  542.  
  543. #else   //  !_DEBUG
  544.  
  545. #define OLEDBGDATA_MAIN(szPrefix)
  546. #define OLEDBGDATA
  547. #define OleDbgAssert(a)
  548. #define OleDbgAssertSz(a, b)
  549. #define OleDbgVerify(a)         (a)
  550. #define OleDbgVerifySz(a, b)    (a)
  551. #define OleDbgOutHResult(lpsz,hr)
  552. #define OleDbgOutScode(lpsz,sc)
  553. #define OLEDBG_BEGIN(lpsz)
  554. #define OLEDBG_END
  555. #define OleDbgOut(lpsz)
  556. #define OleDbgOut1(lpsz)
  557. #define OleDbgOut2(lpsz)
  558. #define OleDbgOut3(lpsz)
  559. #define OleDbgOut4(lpsz)
  560. #define OleDbgOutNoPrefix(lpsz)
  561. #define OleDbgOutNoPrefix1(lpsz)
  562. #define OleDbgOutNoPrefix2(lpsz)
  563. #define OleDbgOutNoPrefix3(lpsz)
  564. #define OleDbgOutNoPrefix4(lpsz)
  565. #define OLEDBG_BEGIN1(lpsz)
  566. #define OLEDBG_BEGIN2(lpsz)
  567. #define OLEDBG_BEGIN3(lpsz)
  568. #define OLEDBG_BEGIN4(lpsz)
  569. #define OLEDBG_END1
  570. #define OLEDBG_END2
  571. #define OLEDBG_END3
  572. #define OLEDBG_END4
  573. #define OleDbgOutRefCnt(lpsz,lpObj,refcnt)
  574. #define OleDbgOutRefCnt1(lpsz,lpObj,refcnt)
  575. #define OleDbgOutRefCnt2(lpsz,lpObj,refcnt)
  576. #define OleDbgOutRefCnt3(lpsz,lpObj,refcnt)
  577. #define OleDbgOutRefCnt4(lpsz,lpObj,refcnt)
  578. #define OleDbgOutRect(lpsz,lpRect)
  579. #define OleDbgOutRect1(lpsz,lpRect)
  580. #define OleDbgOutRect2(lpsz,lpRect)
  581. #define OleDbgOutRect3(lpsz,lpRect)
  582. #define OleDbgOutRect4(lpsz,lpRect)
  583.  
  584. #endif  //  _DEBUG
  585.  
  586.  
  587. /*************************************************************************
  588. ** Function prototypes
  589. *************************************************************************/
  590.  
  591.  
  592. //OLESTD.C
  593. #ifdef NOT_YET
  594. STDAPI_(int) SetDCToAnisotropic(HDC hDC, LPRECT lprcPhysical, LPRECT lprcLogical, LPRECT lprcWindowOld, LPRECT lprcViewportOld);
  595. STDAPI_(int) SetDCToDrawInHimetricRect(HDC, LPRECT, LPRECT, LPRECT, LPRECT);
  596. STDAPI_(int) ResetOrigDC(HDC, int, LPRECT, LPRECT);
  597.  
  598. STDAPI_(int)        XformWidthInHimetricToPixels(HDC, int);
  599. STDAPI_(int)        XformWidthInPixelsToHimetric(HDC, int);
  600. STDAPI_(int)        XformHeightInHimetricToPixels(HDC, int);
  601. STDAPI_(int)        XformHeightInPixelsToHimetric(HDC, int);
  602.  
  603. STDAPI_(void) XformRectInPixelsToHimetric(HDC, LPRECT, LPRECT);
  604. STDAPI_(void) XformRectInHimetricToPixels(HDC, LPRECT, LPRECT);
  605. STDAPI_(void) XformSizeInPixelsToHimetric(HDC, LPSIZEL, LPSIZEL);
  606. STDAPI_(void) XformSizeInHimetricToPixels(HDC, LPSIZEL, LPSIZEL);
  607. STDAPI_(int) XformWidthInHimetricToPixels(HDC, int);
  608. STDAPI_(int) XformWidthInPixelsToHimetric(HDC, int);
  609. STDAPI_(int) XformHeightInHimetricToPixels(HDC, int);
  610. STDAPI_(int) XformHeightInPixelsToHimetric(HDC, int);
  611.  
  612. STDAPI_(void) ParseCmdLine(LPSTR, BOOL FAR *, LPSTR);
  613. #endif // NOT_YET
  614.  
  615. STDAPI_(BOOL) OleStdIsOleLink(LPUNKNOWN lpUnk);
  616. STDAPI_(LPUNKNOWN) OleStdQueryInterface(LPUNKNOWN lpUnk, REFIID riid);
  617. STDAPI_(LPSTORAGE) OleStdCreateRootStorage(LPOLESTR lpszStgName, DWORD grfMode);
  618. STDAPI_(LPSTORAGE) OleStdOpenRootStorage(LPOLESTR lpszStgName, DWORD grfMode);
  619. STDAPI_(LPSTORAGE) OleStdOpenOrCreateRootStorage(LPOLESTR lpszStgName, DWORD grfMode);
  620. STDAPI_(LPSTORAGE) OleStdCreateChildStorage(LPSTORAGE lpStg, LPOLESTR lpszStgName);
  621. STDAPI_(LPSTORAGE) OleStdOpenChildStorage(LPSTORAGE lpStg, LPOLESTR lpszStgName, DWORD grfMode);
  622. STDAPI_(BOOL) OleStdCommitStorage(LPSTORAGE lpStg);
  623. STDAPI OleStdDestroyAllElements(LPSTORAGE lpStg);
  624.  
  625. STDAPI_(LPSTORAGE) OleStdCreateStorageOnHGlobal(
  626.       HANDLE hGlobal,
  627.       BOOL fDeleteOnRelease,
  628.       DWORD dwgrfMode
  629. );
  630. STDAPI_(LPSTORAGE) OleStdCreateTempStorage(BOOL fUseMemory, DWORD grfMode);
  631. STDAPI OleStdDoConvert(LPSTORAGE lpStg, REFCLSID rClsidNew);
  632. STDAPI_(BOOL) OleStdGetTreatAsFmtUserType(
  633.       REFCLSID        rClsidApp,
  634.       LPSTORAGE       lpStg,
  635.       CLSID FAR*      lpclsid,
  636.       CLIPFORMAT FAR* lpcfFmt,
  637.       LPOLESTR FAR*      lplpszType
  638. );
  639. // bole xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  640. STDAPI OleStdDoTreatAsClass(LPOLESTR lpszUserType, REFCLSID rclsid, REFCLSID rclsidNew);
  641. STDAPI_(BOOL) OleStdSetupAdvises(LPOLEOBJECT lpOleObject, DWORD dwDrawAspect,
  642.                LPOLESTR lpszContainerApp, LPOLESTR lpszContainerObj,
  643.                LPADVISESINK lpAdviseSink, BOOL fCreate);
  644. STDAPI OleStdSwitchDisplayAspect(
  645.       LPOLEOBJECT             lpOleObj,
  646.       LPDWORD                 lpdwCurAspect,
  647.       DWORD                   dwNewAspect,
  648.       HGLOBAL                 hMetaPict,
  649.       BOOL                    fDeleteOldAspect,
  650.       BOOL                    fSetupViewAdvise,
  651.       LPADVISESINK            lpAdviseSink,
  652.       BOOL FAR*               lpfMustUpdate
  653. );
  654. STDAPI OleStdSetIconInCache(LPOLEOBJECT lpOleObj, HGLOBAL hMetaPict);
  655. // bolexxxxxxxxxxxxxxxxxxx
  656. STDAPI_(HGLOBAL) OleStdGetData(
  657.       LPDATAOBJECT        lpDataObj,
  658.       CLIPFORMAT          cfFormat,
  659.       DVTARGETDEVICE FAR* lpTargetDevice,
  660.       DWORD               dwAspect,
  661.       LPSTGMEDIUM         lpMedium
  662. );
  663.  
  664. #ifdef NOT_YET
  665. STDAPI_(void) OleStdMarkPasteEntryList(
  666.       LPDATAOBJECT        lpSrcDataObj,
  667.       LPOLEUIPASTEENTRY   lpPriorityList,
  668.       int                 cEntries
  669. );
  670. STDAPI_(int) OleStdGetPriorityClipboardFormat(
  671.       LPDATAOBJECT        lpSrcDataObj,
  672.       LPOLEUIPASTEENTRY   lpPriorityList,
  673.       int                 cEntries
  674. );
  675. #endif // NOT_YET
  676. STDAPI_(BOOL) OleStdIsDuplicateFormat(
  677.       LPFORMATETC         lpFmtEtc,
  678.       LPFORMATETC         arrFmtEtc,
  679.       int                 nFmtEtc
  680. );
  681. STDAPI_(void) OleStdRegisterAsRunning(LPUNKNOWN lpUnk, LPMONIKER lpmkFull, DWORD FAR* lpdwRegister);
  682. STDAPI_(void) OleStdRevokeAsRunning(DWORD FAR* lpdwRegister);
  683. STDAPI_(void) OleStdNoteFileChangeTime(LPOLESTR lpszFileName, DWORD dwRegister);
  684. STDAPI_(void) OleStdNoteObjectChangeTime(DWORD dwRegister);
  685. STDAPI OleStdGetOleObjectData(
  686.       LPPERSISTSTORAGE    lpPStg,
  687.       LPFORMATETC         lpformatetc,
  688.       LPSTGMEDIUM         lpMedium,
  689.       BOOL                fUseMemory
  690. );
  691. STDAPI OleStdGetLinkSourceData(
  692.       LPMONIKER           lpmk,
  693.       LPCLSID             lpClsID,
  694.       LPFORMATETC         lpformatetc,
  695.       LPSTGMEDIUM         lpMedium
  696. );
  697. STDAPI_(HGLOBAL) OleStdGetObjectDescriptorData(
  698.       CLSID               clsid,
  699.       DWORD               dwAspect,
  700.       SIZEL               sizel,
  701.       POINTL              pointl,
  702.       DWORD               dwStatus,
  703.       LPOLESTR            lpszFullUserTypeName,
  704.       LPOLESTR            lpszSrcOfCopy
  705. );
  706. // bolexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  707. STDAPI_(HGLOBAL) OleStdGetObjectDescriptorDataFromOleObject(
  708.       LPOLEOBJECT         lpOleObj,
  709.       LPOLESTR            lpszSrcOfCopy,
  710.       DWORD               dwAspect,
  711.       POINTL              pointl,
  712.       LPSIZEL             lpSizelHim
  713. );
  714. STDAPI_(HGLOBAL) OleStdFillObjectDescriptorFromData(
  715.       LPDATAOBJECT       lpDataObject,
  716.       LPSTGMEDIUM        lpmedium,
  717.       CLIPFORMAT FAR*    lpcfFmt
  718. );
  719. // bolexxxxxxxxxxxxxxxxxxx
  720. STDAPI_(HANDLE) OleStdGetMetafilePictFromOleObject(
  721.       LPOLEOBJECT         lpOleObj,
  722.       DWORD               dwDrawAspect,
  723.       LPSIZEL             lpSizelHim,
  724.       DVTARGETDEVICE FAR* ptd
  725. );
  726.  
  727. STDAPI_(void) OleStdCreateTempFileMoniker(LPOLESTR lpszPrefixString, UINT FAR* lpuUnique, LPOLESTR lpszName, LPMONIKER FAR* lplpmk);
  728. STDAPI_(LPMONIKER) OleStdGetFirstMoniker(LPMONIKER lpmk);
  729. // bolexxxxxxxxxxxxxxxxxxxxxxxxxxxx
  730. STDAPI_(ULONG) OleStdGetLenFilePrefixOfMoniker(LPMONIKER lpmk);
  731. STDAPI OleStdMkParseDisplayName(
  732.       REFCLSID        rClsid,
  733.       LPBC            lpbc,
  734.       LPOLESTR        lpszUserName,
  735.       ULONG FAR*      lpchEaten,
  736.       LPMONIKER FAR*  lplpmk
  737. );
  738. STDAPI_(LPVOID) OleStdMalloc(ULONG ulSize);
  739. STDAPI_(LPVOID) OleStdRealloc(LPVOID pmem, ULONG ulSize);
  740. STDAPI_(void) OleStdFree(LPVOID pmem);
  741. STDAPI_(ULONG) OleStdGetSize(LPVOID pmem);
  742. STDAPI_(void) OleStdFreeString(LPOLESTR lpsz, LPMALLOC lpMalloc);
  743. // bolexxxxxxxxxxxxxxxxxxxxxxxx
  744. STDAPI_(LPOLESTR) OleStdCopyString(LPOLESTR lpszSrc, LPMALLOC lpMalloc);
  745. STDAPI_(ULONG) OleStdGetItemToken(LPOLESTR lpszSrc, LPOLESTR lpszDst,int nMaxChars);
  746.  
  747. STDAPI_(UINT)     OleStdIconLabelTextOut(HDC        hDC,
  748.                                HFONT      hFont,
  749.                                int        nXStart,
  750.                                int        nYStart,
  751.                                UINT       fuOptions,
  752.                                RECT FAR * lpRect,
  753.                                LPOLESTR   lpszString,
  754.                                UINT       cchString,
  755.                                int FAR *  lpDX);
  756.  
  757. // registration database query functions
  758. STDAPI_(UINT)     OleStdGetAuxUserType(REFCLSID rclsid,
  759.                              WORD   wAuxUserType,
  760.                              LPOLESTR  lpszAuxUserType,
  761.                              int    cch,
  762.                              HKEY   hKey);
  763.  
  764. // bolexxxxxxxxxxxxxxxxxxxxxxxxxxx
  765. STDAPI_(UINT)     OleStdGetUserTypeOfClass(REFCLSID rclsid,
  766.                                  LPOLESTR lpszUserType,
  767.                                  UINT cch,
  768.                                  HKEY hKey);
  769.  
  770. STDAPI_(BOOL) OleStdGetMiscStatusOfClass(REFCLSID, HKEY, DWORD FAR *);
  771. STDAPI_(CLIPFORMAT) OleStdGetDefaultFileFormatOfClass(
  772.       REFCLSID        rclsid,
  773.       HKEY            hKey
  774. );
  775.  
  776. STDAPI_(void) OleStdInitVtbl(LPVOID lpVtbl, UINT nSizeOfVtbl);
  777. STDMETHODIMP OleStdNullMethod(LPUNKNOWN lpThis);
  778. STDAPI_(BOOL) OleStdCheckVtbl(LPVOID lpVtbl, UINT nSizeOfVtbl, LPOLESTR lpszIface);
  779. STDAPI_(ULONG) OleStdVerifyRelease(LPUNKNOWN lpUnk, LPOLESTR lpszMsg);
  780. STDAPI_(ULONG) OleStdRelease(LPUNKNOWN lpUnk);
  781.  
  782. STDAPI_(HDC) OleStdCreateDC(DVTARGETDEVICE FAR* ptd);
  783. STDAPI_(HDC) OleStdCreateIC(DVTARGETDEVICE FAR* ptd);
  784. STDAPI_(DVTARGETDEVICE FAR*) OleStdCreateTargetDevice(LPPRINTDLG lpPrintDlg);
  785. // bolexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  786. STDAPI_(BOOL) OleStdDeleteTargetDevice(DVTARGETDEVICE FAR* ptd);
  787. STDAPI_(DVTARGETDEVICE FAR*) OleStdCopyTargetDevice(DVTARGETDEVICE FAR* ptdSrc);
  788. STDAPI_(BOOL) OleStdCopyFormatEtc(LPFORMATETC petcDest, LPFORMATETC petcSrc);
  789. STDAPI_(int) OleStdCompareFormatEtc(FORMATETC FAR* pFetcLeft, FORMATETC FAR* pFetcRight);
  790. STDAPI_(BOOL) OleStdCompareTargetDevice
  791.    (DVTARGETDEVICE FAR* ptdLeft, DVTARGETDEVICE FAR* ptdRight);
  792.  
  793.  
  794. STDAPI_(void) OleDbgPrint(
  795.       int     nDbgLvl,
  796.       LPSTR   lpszPrefix,
  797.       LPSTR   lpszMsg,
  798.       int     nIndent
  799. );
  800. STDAPI_(void) OleDbgPrintAlways(LPSTR lpszPrefix, LPSTR lpszMsg, int nIndent);
  801. STDAPI_(void) OleDbgSetDbgLevel(int nDbgLvl);
  802. STDAPI_(int) OleDbgGetDbgLevel( void );
  803. STDAPI_(void) OleDbgIndent(int n);
  804. STDAPI_(void) OleDbgPrintRefCnt(
  805.       int         nDbgLvl,
  806.       LPSTR       lpszPrefix,
  807.       LPSTR       lpszMsg,
  808.       LPVOID      lpObj,
  809.       ULONG       refcnt
  810. );
  811. STDAPI_(void) OleDbgPrintRefCntAlways(
  812.       LPSTR       lpszPrefix,
  813.       LPSTR       lpszMsg,
  814.       LPVOID      lpObj,
  815.       ULONG       refcnt
  816. );
  817. STDAPI_(void) OleDbgPrintRect(
  818.       int         nDbgLvl,
  819.       LPSTR       lpszPrefix,
  820.       LPSTR       lpszMsg,
  821.       LPRECT      lpRect
  822. );
  823. STDAPI_(void) OleDbgPrintRectAlways(
  824.       LPSTR       lpszPrefix,
  825.       LPSTR       lpszMsg,
  826.       LPRECT      lpRect
  827. );
  828. STDAPI_(void) OleDbgPrintScodeAlways(LPSTR lpszPrefix, LPSTR lpszMsg, SCODE sc);
  829.  
  830. // debug implementation of the IMalloc interface.
  831. STDAPI OleStdCreateDbAlloc(ULONG reserved, IMalloc FAR* FAR* ppmalloc);
  832.  
  833.  
  834. STDAPI_(LPENUMFORMATETC)
  835.   OleStdEnumFmtEtc_Create(ULONG nCount, LPFORMATETC lpEtc);
  836.  
  837. STDAPI_(LPENUMSTATDATA)
  838.   OleStdEnumStatData_Create(ULONG nCount, LPSTATDATA lpStat);
  839.  
  840. STDAPI_(BOOL)
  841.   OleStdCopyStatData(LPSTATDATA pDest, LPSTATDATA pSrc);
  842.  
  843. STDAPI_(HPALETTE)
  844.   OleStdCreateStandardPalette(void);
  845.  
  846. #if defined( OBSOLETE )
  847.  
  848. /*************************************************************************
  849. ** The following API's have been converted into macros:
  850. **          OleStdQueryOleObjectData
  851. **          OleStdQueryLinkSourceData
  852. **          OleStdQueryObjectDescriptorData
  853. **          OleStdQueryFormatMedium
  854. **          OleStdCopyMetafilePict
  855. **          AreRectsEqual
  856. **          OleStdGetDropEffect
  857. **
  858. **    These macros are defined above
  859. *************************************************************************/
  860. STDAPI_(BOOL) AreRectsEqual(LPRECT lprc1, LPRECT lprc2);
  861. STDAPI_(BOOL) OleStdCopyMetafilePict(HANDLE hpictin, HANDLE FAR* phpictout);
  862. STDAPI OleStdQueryOleObjectData(LPFORMATETC lpformatetc);
  863. STDAPI OleStdQueryLinkSourceData(LPFORMATETC lpformatetc);
  864. STDAPI OleStdQueryObjectDescriptorData(LPFORMATETC lpformatetc);
  865. STDAPI OleStdQueryFormatMedium(LPFORMATETC lpformatetc, TYMED tymed);
  866. STDAPI_(DWORD) OleStdGetDropEffect ( DWORD grfKeyState );
  867. #endif  // OBSOLETE
  868.  
  869. #endif  /* RC_INVOKED */
  870.  
  871. #ifdef BJAPAN
  872. unsigned int NthCType( char *pC, int pos );
  873. #endif
  874.  
  875. /*************************************************************************
  876. ** VERSION VERIFICATION INFORMATION
  877. *************************************************************************/
  878.  
  879. // The following magic number is used to verify that the resources we bind
  880. // to our EXE are the same "version" as the LIB (or DLL) file which
  881. // contains these routines.  This is not the same as the Version information
  882. // resource that we place in OLE2UI.RC, this is a special ID that we will
  883. // have compiled in to our EXE.  Upon initialization of OLE2UI, we will
  884. // look in our resources for an RCDATA called "VERIFICATION" (see OLE2UI.RC),
  885. // and make sure that the magic number there equals the magic number below.
  886.  
  887.  
  888. #define OLEUI_VERSION_MAGIC 0x4D42
  889.  
  890. #endif // _BOLESTD_H_
  891.